package org.dromara.admin.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 签约状态: SIGNING(签约中), AUDIT(审核中), SUCCESS(完成), DEFAULT(违约)
 */
@Getter
@AllArgsConstructor
public enum SigningStatus {

    SIGNING("SIGNING", "签约中"),
    AUDIT("AUDIT", "审核中"),
    SUCCESS("SUCCESS", "完成"),
    DEFAULT("DEFAULT", "违约");

    private final String code;
    private final String info;

    /**
     * 根据code代码获取枚举类型
     *
     * @param code 代码（如："PENDING"）
     * @return 对应的枚举类型
     * @throws IllegalArgumentException 如果找不到匹配的枚举类型
     */
    public static SigningStatus getByCode(String code) {
        for (SigningStatus type : values()) {
            if (type.getCode().equalsIgnoreCase(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("无效的类型代码: " + code);
    }

    /**
     * 根据info信息获取枚举类型
     *
     * @param info 类型信息（如："审核中"）
     * @return 对应的枚举类型
     * @throws IllegalArgumentException 如果找不到匹配的枚举类型
     */
    public static SigningStatus getByInfo(String info) {
        for (SigningStatus type : values()) {
            if (type.getInfo().equals(info)) {
                return type;
            }
        }
        throw new IllegalArgumentException("无效的类型: " + info);
    }
}
